<template>
	<view class="userofferdetail">
		<view class="goodsinfo">
			<view class="name">
				{{orderinfo.title}}
			</view>
			<view class="specs">
				<view class="price">
					<text class="pricenum">￥{{orderinfo.price}}</text>
				</view>
			</view>
		</view>
		<view class="roleinfo" v-for="(item,index) in games" :key="index">
			<view class="title">
				角色信息
			</view>
			<view class="rolebox">
				<view class="role-li">
					<view class="left">
						大区：
					</view>
					<view class="right">
						{{item.zone}}
					</view>
				</view>
				<view class="role-li">
					<view class="left">
						服务器：
					</view>
					<view class="right">
						{{item.server}}
					</view>
				</view>
				<view class="role-li">
					<view class="left">
						天赋：
					</view>
					<view class="right">
						{{item.talent}}
					</view>
				</view>
				<view class="role-li">
					<view class="left">
						职业：
					</view>
					<view class="right">
						{{item.job}}
					</view>
				</view>
				<view class="role-li">
					<view class="left">
						阵营：
					</view>
					<view class="right">
						{{item.camp}}
					</view>
				</view>
				<view class="role-li">
					<view class="left">
						装等：
					</view>
					<view class="right">
						{{item.eq_level}}
					</view>
				</view>
			</view>
		</view>
		<view class="detail">
			<view class="title">
				悬赏内容
			</view>
			<rich-text class="msg" :nodes="orderinfo.desc"></rich-text>
		</view>
		<view class="footer">
			<view class="right">
				<view class="btns">
					<view class="buynow" @click="offerOrder">
						立即接单
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		userofferdetail,
		offerOrder
	} from "@/api/offer.js"
	export default {
		data() {
			return {
				order_id: '',
				orderinfo: {},
				goods: [],
				num: '',
				games: []
			}
		},
		onLoad(e) {
			if (e.id) {
				this.order_id = e.id
				this.userofferdetail()
			}

		},
		onShareAppMessage() {

		},
		onShareTimeline() {

		},
		methods: {
			offerOrder() {
				var that = this
				uni.showModal({
					title: '温馨提示',
					content: '是否立即接单?',
					success(res) {
						if (res.confirm) {
							offerOrder({
								order_id: that.order_id
							}).then(res => {
								uni.$showMsg(res.msg)
								if (res.code == 0) {
									setTimeout(() => {
										uni.redirectTo({
											url: '/pages/user/reward/rewardlist'
										})
									}, 800)
								}
							})
						}
					}
				})
			},
			toHome() {
				uni.switchTab({
					url: '/pages/index/index'
				})
			},

			userofferdetail() {
				userofferdetail({
					id: this.order_id
				}).then(res => {
					if (res.code == 0) {
						this.orderinfo = res.data.order
						this.games = res.data.games
					}
				})
			},
		}
	}
</script>

<style lang="scss">
	page {
		padding-bottom: 10px;
	}

	.userofferdetail {
		background: #f2f2f2;
		min-height: 100vh;
		height: 100%;
		/* #ifdef H5 */
		min-height: calc(100vh - 44px);
		/* #endif */
		padding: 10px;
		box-sizing: border-box;
	}

	.uni-swiper {
		height: 350px;

		.swiper-item {
			image {
				width: 100%;
				height: 350px;
			}
		}
	}

	.roleinfo {
		margin: 0 auto;
		box-sizing: border-box;
		margin-top: 10px;
		background: #fff;
		border-radius: 8px;
		padding: 0 10px;
		padding-bottom: 10px;

		.title {
			text-align: center;
			font-size: 12px;
			color: #777;
			padding: 30rpx;
		}

		.rolebox {
			display: flex;
			align-items: center;
			flex-wrap: wrap;
		}

		.role-li {
			display: flex;
			align-items: center;
			padding: 5px 10px;
			font-size: 14px;
			color: #777;
			width: 50%;
			box-sizing: border-box;
			justify-content: space-between;

			.left {
				width: 60px;
			}

			.right {
				color: #000;
			}
		}
	}

	.goodsinfo {
		background: #fff;
		padding: 25rpx;

		.name {
			letter-spacing: 1px;
			font-weight: bold;
			font-size: 17px;
		}

		.content {
			font-size: 14px;
			color: #777;
			margin-top: 10px;
			max-height: 40px;
			line-height: 20px;
			overflow: hidden;
			display: -webkit-box;
			-webkit-line-clamp: 2;
			-webkit-box-orient: vertical;
			overflow: hidden;
		}

		.specs {
			display: flex;
			justify-content: space-between;
			margin-top: 10px;

			.price {
				font-size: 14px;

				.pricenum {
					font-weight: bold;
					color: #FF5A00;
					margin-right: 10rpx;
					font-size: 18px;
				}
			}

			.num {
				background: #efefef;
				padding: 10rpx 30rpx;
				font-size: 14px;
				color: #777;
				border-top-left-radius: 10px;
				border-bottom-left-radius: 10px;
			}
		}
	}

	.detail {
		background-color: #FFFFFF;
		min-height: 200rpx;
		padding-bottom: 130rpx;
		margin-top: 10px;
		box-sizing: border-box;
		padding: 0 10px;

		.title {
			text-align: center;
			padding: 30rpx;
			color: #777;
		}

		image {
			width: 92%;
			margin-left: 4%;
		}
	}

	.footer {
		position: fixed;
		bottom: 0;
		width: 100%;
		display: flex;
		background: #fff;
		box-shadow: 0 -1px 3px #dddddd;
		max-width: 500px;
		left: 0;


		.right {
			flex: 1;
			display: flex;
			color: #fff;
			text-align: center;
			justify-content: center;
			box-sizing: border-box;
			height: 100rpx;

			.btns {
				display: flex;
				width: 90%;
				border-radius: 10px;
				height: 80rpx;
				line-height: 80rpx;
				margin-top: 10rpx;
				overflow: hidden;
			}

			.joincart {
				width: 50%;
				background: #FFB049;
			}

			.buynow {
				width: 100%;
				background: #050B18;
			}
		}
	}
</style>